package open.witype.filetiper.custom.Slidingmenu;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by Typer on 2015/5/9 0009.
 * 承载菜单的布局
 */
public class BehindViewContent extends SlidingContentBase {

    public static final int ID = 0xFFF2;

    private int mSecondaryWidthOffset;

    private int mWidthOffset;

    private View aboveContent;

    public BehindViewContent(Context context) {
        this(context, null);
        setId(ID);
    }

    public BehindViewContent(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = getDefaultSize(0,widthMeasureSpec);
        int height = getDefaultSize(0,heightMeasureSpec);
        setMeasuredDimension(mWidthOffset, height);
        int contentWidth = getChildMeasureSpec(widthMeasureSpec,0,width);
        int contentHeight = getChildMeasureSpec(heightMeasureSpec,0,height);
        mContent.measure(contentWidth, contentHeight);
    }

    public void setWidthOffset(int mWidth){
        this.mWidthOffset = mWidth;
        requestLayout();
    }

    public int getWidthOffset() {
        return mWidthOffset;
    }

    public void setAboveContent(View aboveContent) {
        this.aboveContent = aboveContent;
    }

    public int getRightBound(){
        return mContent.getRight();
    }

    public int getLeftBound(){
        return mContent.getLeft();
    }

    public int getLeftRelativeBound(){
        return mContent.getLeft() - getRightBound();
    }

    public int getSecondaryLeftRelativeBound(){
        return mContent.getLeft() - mSecondaryWidthOffset;
    }

    public int getRightRelativeBound(){
        return getLeftBound();
    }

    public void setmSecondaryWidthOffset(int offset){
        this.mSecondaryWidthOffset = offset;
    }
}
